// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
	"fmt"
	"log"

	"github.com/howeyc/fsnotify"
)

func main() {
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("start")
	//	return
	done := make(chan int)
	go func() {
		for {
			select {
			case ev := <-watcher.Event:
				log.Println("event:", ev)
			case err := <-watcher.Error:
				log.Println("error:", err)
			}
		}
	}()

	//监听指定的文件的变化
	err = watcher.Watch("/tmp/foo")
	//	err = watcher.WatchFlags("/tmp/foo", fsnotify.FSN_MODIFY)
	if err != nil {
		log.Fatal(err)
	}

	<-done
}
